package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.OrderBean;
import com.project.service.IOrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("myOrder")
public class OrderController {
    @Autowired
    private IOrderService orderService;
    @GetMapping("myOrderList")
    public Page<OrderBean> myOrderList(@RequestParam("pageNO") Integer pageNO,
                                       @RequestParam("username") String username) {
        Page<OrderBean>page=new Page<>();
        IPage<OrderBean>iPage= orderService.myOrderList(pageNO,username);
        BeanUtils.copyProperties(iPage,page);
        return page;
    }
    @GetMapping("updateStatus")
    public String updateStatus(@RequestParam("orderId") Integer orderId){
        orderService.updateStatus(orderId);
        return "ok";
    }

}
